import time

from public.action import *
from public.business import *
from public.testData import *
from public.tools import *
from selenium.webdriver.support.select import Select


testCase = "DBshop006_删除订单"

firefox=openBrowser(urlAdmin)
DBshopLoginAdmin(firefox)
rootPath= get_pro_rootpath()
filePath  = rootPath+r'\public\order4.txt'
orderID = readFile(filePath)
# 1.点击销售管理订单管理界面。
DBshopEnterMenu2(firefox,"销售管理","订单管理")
s=firefox.find_element_by_xpath("//body").text
l="订单数\："
r="\)"
num1=reGetString(s,l,r)
# 2.在订单号查询框输入orderID，点击“搜索”按钮。
DBshopSearchOrderID(firefox,orderID)
# 3.勾选，点击删除
firefox.find_element_by_name('order_id[]').click()
s1=Select(firefox.find_element_by_id('allEdit'))
s1.select_by_visible_text('删除')
firefox.find_element_by_xpath('//button[contains(.,"提交操作")]').click()
firefox.switch_to.alert.accept()
time.sleep(5)
#删除前的订单数=删除后的订单数+1
s=firefox.find_element_by_xpath("//body").text
num2=reGetString(s,l,r)


if int(num1)==int(num2)+1:
    writeLog("%s 测试通过" % (testCase))
else:
    writeLog("%s 测试失败" % (testCase))
    getPhoto(firefox)
firefox.quit()
